<?php
include ('../../includes/global.php');

$dbcfg = Sys::Gp(array('dbcfg', 'sevenel'));

switch ($_GET['t']) {
    //所有用户组
    case 'group':
        $fldata = Dgd(array(
            'db' => 'd_sevenel',
            'cd' => "del!=1  order by id ",
            'tn' => "rtp"
                ));
        $_R['total'] = count($fldata);

        foreach ($fldata as $v) {
            $tmp['id'] = $v['id'];
            $tmp['title'] = $v['tt'];
            $tmp['intro'] = $v['ct'];
            $_R['result'][] = $tmp;
        }

        echo json_encode($_R);
        break;

    //单个用户权限
    case 'user':
        $d = Dgd(array(
            'db' => 'd_sevenel',
            'cd' => "del!=1 and id='{$_POST['uid']}'  order by id ",
            'tn' => "user"
                ));
        $rcfg = implode(',',explode(',',$d[0]['rcfg']));


        echo $rcfg;
        break;

    //保存用户权限
    case 'save':
        $_U['rcfg'] = $_POST['gids'];
        
        mysql_query("update se_user set rcfg='{$_POST['gids']}' where id='{$_POST['uid']}'");
        echo 'ok';
        break;

    //所有用户
    default:
        $fldata = Dgd(array(
            'db' => 'd_sevenel',
            'cd' => "del!=1 and user!='admin' order by id ",
            'tn' => "user"
                ));
        $_R['total'] = count($fldata);

        foreach ($fldata as $v) {
            $tmp['id'] = $v['id'];
            $tmp['user'] = $v['user'];
            $_R['result'][] = $tmp;
        }

        echo json_encode($_R);
        break;
}
